const { Controller, } = require('egg')
const { getResult } = require('../assets/utils')

class UserController extends Controller {
  async getUsers() {
    const { ctx } = this
    const userList = await ctx.service.user.fetch()
    ctx.body = getResult({
      data: userList
    })
  }

  async getUser() {
    const { ctx } = this
    const { id } = ctx.params
    const user = await ctx.service.user.find(id)
    ctx.body = getResult({
      data: user
    })
  }
}

module.exports = UserController
